package com.example.demo.service.serviceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.entity.ParamBase;
import com.example.demo.common.entity.ParamPage;
import com.example.demo.common.util.*;
import com.example.demo.common.util.ListResult;
import com.example.demo.component.StringHelper;
import com.example.demo.dao.mapper.DbClueInfodxjMapper;
import com.example.demo.service.DbClueInfodxjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class DbClueInfodxjServiceImpl implements DbClueInfodxjService {

	@Autowired
	DbClueInfodxjMapper dbClueInfoMapper;

	// 新增或修改商机信息
	// 事务
	@Transactional
	@Override
	public OptResult InsertOrUpdate(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();

		// 验证必填字段非空
		// 补充字段
		// 参数初始化，创建人/修改人为空默认赋值当前用户ID，创建时间/修改时间为空默认赋值当前服务器时间，所属公司部门科室赋值当前用户所属公司、部门、科室ID
		com.example.demo.common.util.UserEntity userEntity = BucnUtil.tokenUser(token);
		List<Map<String, Object>> list = dbClueInfoMapper.selectUserInfoByUserId(userEntity.getUserID());
		if (list == null || list.size() <= 0) {
			return OptResultBuilder.createFail().build();
		}
		param.put("compId", list.get(0).get("compId"));
		param.put("deptId", list.get(0).get("deptId"));
		param.put("groupId", list.get(0).get("groupId"));

		// 判断是否有主键 有就是更新 没有就是新增
		if (param.get("id") != null && param.get("id") != "") {
			if (param.get("updateControlId") == null) {
				BucnUtil.throwMessage("update_control_id");
			}
			// 更新
			// 补充公共字段
			BucnUtil.userWrapUpdate(param, token);
			// 1、修改商机主表逻辑T_DB_CLUE_INFO
			BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.updateClueInfo(param));
			// 2、删除原商机ID相关的联系人信息，T_DB_CLUE_LINKMAN_INFO
			Map<String, Object> hashMap = new HashMap<String, Object>();
			hashMap.put("clueId", param.get("id"));
			dbClueInfoMapper.deleteClueLinkManInfo(hashMap);
			// 遍历联系人信息集合，
			// 3.1 带入商机ID新增联系人信息逻辑T_DB_CLUE_LINKMAN_INFO
			List<Map<String, Object>> maps = (List<Map<String, Object>>) param.get("linkman");
			for (Map<String, Object> map : maps) {
				BucnUtil.userWrapInsert(map, token);
				map.put("clueId", param.get("id"));
				map.put("id", StringHelper.GetGUID());
				dbClueInfoMapper.insertClueLinkManInfo(map);
			}

		} else {
			// 新增
			// 1、验证线索编码是否已经存在
//			BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.verifyClueCode(param, null));
			int count=dbClueInfoMapper.verifyClueCode(param, null);
			if(count>0) {
				BucnUtil.throwMessage("clueCode 已经存在");
			}
			// 2、新增商机主表逻辑T_DB_CLUE_INFO
			BucnUtil.userWrapInsert(param, token);
			param.put("id", StringHelper.GetGUID());
			BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertClueInfo(param));

			// 3、遍历联系人信息集合：
			// 3.1、带入商机主表ID，新增商机联系人信息逻辑T_DB_CLUE_LINKMAN_INFO
			List<Map<String, Object>> maps = (List<Map<String, Object>>) param.get("linkman");
			for (Map<String, Object> map : maps) {
				BucnUtil.userWrapInsert(map, token);
				map.put("clueId", param.get("id"));
				map.put("id", StringHelper.GetGUID());
				dbClueInfoMapper.insertClueLinkManInfo(map);
			}

		}
		return OptResultBuilder.createOk().build();
	}

	// 获取商机信息（含分页数据）
	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> GetClueList(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		com.example.demo.common.util.ListResult<Map<String, Object>> result = null;

		if (paramPage.getParam().get("clueId") == null || paramPage.getParam().get("culeId") == "") {
			// param.clueId为空查询商机列表
			List<Map<String, Object>> list = dbClueInfoMapper.dbClueInfoPage(paramPage.getParam(), page);
			result = BucnUtil.page2ListResult(page, list);

		} else {
			// param.clueId非空查询商机详情
			// 1、根据商机ID查询商机主表逻辑T_DB_CLUE_INFO、T_DB_CLUE_INFO
			// 2、根据商机ID查询商机联系人信息表T_DB_CLUE_LINKMAN_INFO
			// 3、根据商机ID查询跟进历史信息T_BU_CLUE_FOLLOWUP
			List<Map<String, Object>> list = dbClueInfoMapper.selectdbClueInfoByClueId(paramPage.getParam(), page);
			result = BucnUtil.page2ListResult(page, list);

		}
		return result;

	}

	// 商机跟踪
	// 事务
	@Transactional
	@Override
	public OptResult FollowUpClue(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		// 字段校验 t_bucn_cdata_validfield_base 配置表配置
//            BucnUtil.fieldCheck("dic_info", param);
		BucnUtil.userWrapInsert(param, token);
		param.put("id", StringHelper.GetGUID());
		// 1、保存跟进记录到T_BU_CLUE_FOLLOWUP表
		BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertDbClueFollowUp(param));
		// 2、保存附件信息到T_SYS_ATTACHMENT_BILL表
		List<Map<String, Object>> maps = (List<Map<String, Object>>) param.get("attachement");
		for (Map<String, Object> map : maps) {
			BucnUtil.userWrapInsert(map, token);
			map.put("id", StringHelper.GetGUID());
			dbClueInfoMapper.insertSysAttachmentBill(map);
		}
		// 3、更新商机记录T_DB_CLUE_INFO表
		// 根据线索ID查询线索信息
		List<Map<String, Object>> list = dbClueInfoMapper.selectdbClueInfoByClueId1(param, null);
		if (list == null || list.size() <= 0) {
			BucnUtil.throwMessage("clueId不存在");
		}
		Map<String, Object> map = new HashMap<String, Object>();
		com.example.demo.common.util.UserEntity userEntity = BucnUtil.tokenUser(token);
		String userId = userEntity.getUserID();
		// 2.1意向级别 =本次意向级别，如果是F级别则默认为原跟进级别
		if (param.get("intentLevel").equals("F")) {
			map.remove("intentLevel");
		}
		// 2.2意向级别为D则意向阶段=3
		if (param.get("intentLevel").equals("D")) {
			map.put("intentLevel", 3);
		}
		// 2.3线索签约额 2.4签约时间
		map.put("signAmount", param.get("signAmount"));
		map.put("signDate", param.get("signDate"));
		// 2.5首次跟进时间为空则=当前时间
		if (list.get(0).get("firstFollowupDate") == null || list.get(0).get("firstFollowupDate") == "") {
			map.put("firstFollowupDate", LocalDateTime.now());
		}
		// 2.6跟进次数=跟进次数+1
		map.put("followupCount", ((int) list.get(0).get("followupCount") + 1));
		// 2.7最近一次跟进时间 =当前时间
		map.put("lastFollowupDate", LocalDateTime.now());
		// 2.8最后跟进人 =当前用户ID
		map.put("lastFollowupMan", userId);
		// 2.9下次跟进人 =当前用户ID
		map.put("nextFollowupMan", userId);
		// 3.0战败时间 =战败时间
		map.put("failDate", param.get("failDate"));
		// 3.1战败原因 3.2战败描述
		map.put("failReson", param.get("failReson"));
		map.put("failDesc", param.get("failDesc"));
		// 3.3线索状态 （意向级别H、M、U、L=跟进中2，D=签约5，F=待审核3）
		if (param.get("intentLevel") == "H" || param.get("intentLevel") == "M" || param.get("intentLevel") == "U"
				|| param.get("intentLevel") == "L") {
			map.put("status", "2");
		}
		if (param.get("intentLevel") == "D") {
			map.put("status", "5");
		}
		if (param.get("intentLevel") == "F") {
			map.put("status", "3");
		}
		map.put("id", list.get(0).get("id"));
		map.put("updateControlId", list.get(0).get("updateControlId"));
		BucnUtil.userWrapUpdate(map, token);
		BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.updateClueInfo(map));
		return OptResultBuilder.createOk().build();
	}

	// 分配商机DistClue
	@Override
	public ListResult<Map<String, Object>> GetClueFollowList(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		// 参数校验及参数初始化 1、如果param.clueId为空则提示错误
		if (paramPage.getParam().get("clueId") == null || paramPage.getParam().get("clueId") == "") {
			BucnUtil.throwMessage("clueId is null");
		}
		List<Map<String, Object>> list = dbClueInfoMapper.GetClueFollowList(paramPage.getParam(), page);
		com.example.demo.common.util.ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

	// 分配商机DistClue
	// 事务
	@Transactional
	@Override
	public OptResult DistClue(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		// 获取发送方用户信息
		com.example.demo.common.util.UserEntity userEntity = BucnUtil.tokenUser(token);
		String userId = userEntity.getUserID();
		String userName = userEntity.getUserName();
		if (param.get("clue") == null) {
			BucnUtil.throwMessage("clue is null");
		}
		List<Map<String, Object>> listObject = (List<Map<String, Object>>) param.get("clue");

		listObject.forEach(mapObject -> {
			if (mapObject.get("clueId") != null && mapObject.get("clueId") != "") {
				if (mapObject.get("updateControlId") == null) {
					BucnUtil.throwMessage("update_control_id");
				}
				// 获取商机记录T_DB_CLUE_INFO中的原负责人信息
				List<Map<String, Object>> list = dbClueInfoMapper.selectdbClueInfoByClueId1(mapObject, null);
				if (list == null || list.size() <= 0) {
					BucnUtil.throwMessage("clueInfo is null");

				}
				Map<String, Object> oldMap = new HashMap<String, Object>();
				oldMap.put("manScId", list.get(0).get("manScId"));
				oldMap.put("manBaId", list.get(0).get("manBaId"));
				oldMap.put("manPmId", list.get(0).get("manPmId"));
				oldMap.put("manSc", list.get(0).get("manSc"));
				oldMap.put("manBa", list.get(0).get("manBa"));
				oldMap.put("manPm", list.get(0).get("manPm"));

				// 补充公共字段
				BucnUtil.userWrapUpdate(mapObject, token);
				mapObject.put("updateControlId", list.get(0).get("updateControlId"));
				// 更新商机记录T_DB_CLUE_INFO对应的负责人信息
				BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.updateClueInfo(mapObject));
				// 添加一条消息通知
				mapObject.put("id", StringHelper.GetGUID());
				mapObject.put("msgTitle", "划转通知");
				mapObject.put("msgBody", "您获得1条新的线索！");
				mapObject.put("msgDate", LocalDateTime.now());
				BucnUtil.userWrapInsert(mapObject, token);
				BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageInfo(mapObject));
				// IS_SEND_OLD='1'通知原负责人
				if (mapObject.get("isSendOld").equals("1")) {
					oldMap.put("msgId", mapObject.get("id"));
					BucnUtil.userWrapInsert(oldMap, token);
					Map<String, Object> map1 = new HashMap<String, Object>();
					Map<String, Object> map2 = new HashMap<String, Object>();
					Map<String, Object> map3 = new HashMap<String, Object>();
					map1.put("msgId", mapObject.get("id"));
					map1.put("sUserId", userId);
					map1.put("sUserName", userName);
					map1.put("rUserId", oldMap.get("manScId"));
					map1.put("rUserName", oldMap.get("manSc"));
					map1.put("id", StringHelper.GetGUID());
					BucnUtil.userWrapInsert(map1, token);
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map1));
					map2.put("msgId", mapObject.get("id"));
					map2.put("sUserId", userId);
					map2.put("sUserName", userName);
					map2.put("rUserId", oldMap.get("manBaId"));
					map2.put("rUserName", oldMap.get("manBa"));
					map2.put("id", StringHelper.GetGUID());
					BucnUtil.userWrapInsert(map2, token);
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map2));

					map3.put("msgId", mapObject.get("id"));
					map3.put("sUserId", userId);
					map3.put("sUserName", userName);
					map3.put("rUserId", oldMap.get("manPmId"));
					map3.put("rUserName", oldMap.get("manPm"));
					map3.put("id", StringHelper.GetGUID());
					BucnUtil.userWrapInsert(map3, token);
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map3));
				}
				// IS_SEND_NEW='1'通知新负责人
				if (mapObject.get("isSendNew").equals("1")) {
					mapObject.put("msgId", mapObject.get("id"));
					BucnUtil.userWrapInsert(mapObject, token);
					Map<String, Object> map1 = new HashMap<String, Object>();
					Map<String, Object> map2 = new HashMap<String, Object>();
					Map<String, Object> map3 = new HashMap<String, Object>();
					map1.put("msgId", mapObject.get("id"));
					map1.put("sUserId", userId);
					map1.put("sUserName", userName);
					map1.put("rUserId", mapObject.get("manScId"));
					map1.put("rUserName", mapObject.get("manSc"));
					map1.put("id", StringHelper.GetGUID());
					BucnUtil.userWrapInsert(map1, token);
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map1));
					map2.put("msgId", mapObject.get("id"));
					map2.put("sUserId", userId);
					map2.put("sUserName", userName);
					map2.put("rUserId", mapObject.get("manBaId"));
					map2.put("rUserName", mapObject.get("manBa"));
					BucnUtil.userWrapInsert(map2, token);
					map2.put("id", StringHelper.GetGUID());
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map2));

					map3.put("msgId", mapObject.get("id"));
					map3.put("sUserId", userId);
					map3.put("sUserName", userName);
					map3.put("rUserId", mapObject.get("manPmId"));
					map3.put("rUserName", mapObject.get("manPm"));
					map3.put("id", StringHelper.GetGUID());
					BucnUtil.userWrapInsert(map3, token);
					BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map3));

				}

			} else {
				BucnUtil.throwMessage("clue is null");
			}

		});

		return OptResultBuilder.createOk().build();
	}

	// 战败审核线索列表 GetCheckFailClueList
	@Override
	public ListResult<Map<String, Object>> GetCheckFailClueList(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.GetCheckFailClueList(paramPage.getParam(), page);
		com.example.demo.common.util.ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

	// 战败审核CheckFailClue
	@Override
	public OptResult CheckFailClue(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		if (param.get("clue") == null || param.get("clue") == "") {
			BucnUtil.throwMessage("clue is null");
		}
		List<Map<String, Object>> listObject = (List<Map<String, Object>>) param.get("clue");
		listObject.forEach(mapObject -> {
			if (mapObject.get("clueId") == null || mapObject.get("clueId") == "") {
				BucnUtil.throwMessage("clueId is null");
			}

			// 补充公共字段
			BucnUtil.userWrapUpdate(mapObject, token);
			List<Map<String, Object>> list2 = dbClueInfoMapper.selectdbClueInfoByClueId1(mapObject, null);
			mapObject.put("updateControlId", list2.get(0).get("updateControlId"));
			// 更新商机记录T_DB_CLUE_INFO表
			BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.CheckFailClue(mapObject));

			// 新增一条跟进记录T_BU_CLUE_FOLLOWUP
			// 查出最新的一条跟进记录
			List<Map<String, Object>> list1 = dbClueInfoMapper.GetClueFollowList(mapObject, null);
			if (list1 == null || list1.size() <= 0) {
				BucnUtil.throwMessage("followup is null");
			}
			//将最新的一条跟进记录的数据取出放到参数列表中
			mapObject.put("originaiPlanFollowupContent", list1.get(0).get("originaiPlanFollowupContent"));
			mapObject.put("originaiPlanFollowupDate", new Date());
			mapObject.put("followupDesc", list1.get(0).get("followupDesc"));
			mapObject.put("otherDesc", list1.get(0).get("otherDesc"));
			mapObject.put("followupType", list1.get(0).get("followupType"));
			mapObject.put("followupDate", list1.get(0).get("followupDate"));
			mapObject.put("lastIntentLevel", list1.get(0).get("lastIntentLevel"));
			mapObject.put("intentLevel", 'F');
			mapObject.put("followupMan", mapObject.get("manBaId"));
			// 补充公共字段
			BucnUtil.userWrapInsert(mapObject, token);
			mapObject.put("id", StringHelper.GetGUID());
			BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertDbClueFollowUp(mapObject));
			// 获取发送方用户信息
			UserEntity userEntity = BucnUtil.tokenUser(token);
			String userId = userEntity.getUserID();
			String userName = userEntity.getUserName();
			if (mapObject.get("checkStatu") == "4") {
				// 添加一条消息通知
				mapObject.put("id", StringHelper.GetGUID());
				mapObject.put("msgTitle", "战败审核通过");
				mapObject.put("msgBody", "您有1条战败申请被审核！");
				mapObject.put("msgDate", LocalDateTime.now());
				BucnUtil.userWrapInsert(mapObject, token);
				BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageInfo(mapObject));
				Map<String, Object> map1 = new HashMap<String, Object>();
				map1.put("msgId", mapObject.get("id"));
				map1.put("sUserId", userId);
				map1.put("sUserName", userName);
				map1.put("rUserId", mapObject.get("manBaId"));
				map1.put("id", StringHelper.GetGUID());
				BucnUtil.userWrapInsert(map1, token);
				BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map1));
			}
			if (mapObject.get("checkStatu") == "2") {
				// 添加一条消息通知
				mapObject.put("id", StringHelper.GetGUID());
				mapObject.put("msgTitle", "战败审核不通过");
				mapObject.put("msgBody", "您有1条战败申请被驳回！");
				mapObject.put("msgDate", LocalDateTime.now());
				BucnUtil.userWrapInsert(mapObject, token);
				Map<String, Object> map1 = new HashMap<String, Object>();
				map1.put("msgId", mapObject.get("id"));
				map1.put("sUserId", userId);
				map1.put("sUserName", userName);
				map1.put("rUserId", mapObject.get("manBaId"));
				map1.put("id", StringHelper.GetGUID());
				BucnUtil.userWrapInsert(map1, token);
				BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertSysMessageUser(map1));
			}

		});
		return OptResultBuilder.createOk().build();
	}

	// 删除商机 DelClue
	// 事务
	@Transactional
	@Override
	public OptResult DelClue(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		if (param.get("id") == null||param.get("id")=="") {
			BucnUtil.throwMessage("id");
		}
		if (param.get("updateControlId") == null||param.get("updateControlId")=="") {
			BucnUtil.throwMessage("updateControlId");
		}
		BucnUtil.userWrapUpdate(param, token);
		BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.DelClue(param));
		return OptResultBuilder.createOk().build();
	}

	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> selectClueSource(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.selectClueSource(paramPage.getParam(), page);
		com.example.demo.common.util.ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;

	}

	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> selectCustName(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.selectCustName(paramPage.getParam(), page);
		com.example.demo.common.util.ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> selectIntentProduct(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.selectIntentProduct(paramPage.getParam(), page);
		com.example.demo.common.util.ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> selectIntentLevel(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.selectIntentLevel(paramPage.getParam(), page);
		ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}



	// 事务
	@Transactional
	@Override
	public ListResult<Map<String, Object>> dbClueLinkManInfoPage(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.dbClueLinkManInfoPage(paramPage.getParam(), page);
		ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

	// 事务
	@Transactional
	@Override
	public OptResult deleteClueLinkManInfo(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		if (param.get("id") == null) {
			BucnUtil.throwMessage("id");
		}
		if (param.get("updateControlId") == null) {
			BucnUtil.throwMessage("updateControlId");
		}
		BucnUtil.userWrapUpdate(param, token);
		BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.deleteClueLinkManInfo(param));
		return OptResultBuilder.createOk().build();
	}

	// 事务
	@Transactional
	@Override
	public OptResult insertClueLinkManInfo(ParamBase<Map<String, Object>> paramBase, String token) {
		// TODO Auto-generated method stub
		Map<String, Object> param = paramBase.getParam();
		BucnUtil.userWrapInsert(param, token);
		param.put("id", StringHelper.GetGUID());
		BucnInvoker.dmlInvoke(() -> dbClueInfoMapper.insertClueLinkManInfo(param));
		return OptResultBuilder.createOk().build();
	}

	@Override
	public ListResult<Map<String, Object>> dbClueFollowupPage(ParamPage<Map<String, Object>> paramPage) {
		// TODO Auto-generated method stub
		IPage<Map<String, Object>> page = new Page<>(paramPage.getPageIndex(), paramPage.getPageSize());
		List<Map<String, Object>> list = dbClueInfoMapper.dbClueFollowupPage(paramPage.getParam(), page);
		ListResult<Map<String, Object>> result = BucnUtil.page2ListResult(page, list);
		return result;
	}

}
